package com.tdkj.action.backstage.information;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;

import com.tdkj.action.BaseAction;
import com.tdkj.model.information.BeanBaseInfo;
import com.tdkj.model.information.BeanInfoComment;
import com.tdkj.service.information.IBeanInfoCommentService;
public class InfoCommentAction  extends BaseAction{
	private Long id;
	private BeanInfoComment comment;
	private IBeanInfoCommentService infoCommentService;
	private List<BeanInfoComment> comments=new ArrayList<BeanInfoComment>();
	private String[] ids;
	public String deleteAll() {
		if (null != ids) {
			for (String idtemp : ids) {
				this.getBaseService().delete(Long.parseLong(idtemp), BeanInfoComment.class);
			}
		}
		return findAll();
	}
	public String[] getIds() {
		return ids;
	}

	public void setIds(String[] ids) {
		this.ids = ids;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public List<BeanInfoComment> getComments() {
		return comments;
	}
	public void setComments(List<BeanInfoComment> comments) {
		this.comments = comments;
	}
	public BeanInfoComment getComment() {
		return comment;
	}
	public void setComment(BeanInfoComment comment) {
		this.comment = comment;
	}
	public IBeanInfoCommentService getInfoCommentService() {
		return infoCommentService;
	}
	@Resource
	public void setInfoCommentService(IBeanInfoCommentService infoCommentService) {
		this.infoCommentService = infoCommentService;
	}
	public String findAll(){
		Criteria criteria = this.createCriteria(BeanInfoComment.class);
		criteria.addOrder(Order.desc("createtime"));// 对状态进行排序
		this.queryByPage(criteria, "infoCommentAction!findAll.action", 10);
		return "findAll";
	}
	//更新评论状态
	public String updateStatus(){
		comments=infoCommentService.setStatus(this.getId());
		return findAll();
	}
	//获取评论
	public String findContent(){
		comment=infoCommentService.findById(this.getId(), BeanInfoComment.class);
		return "findContent";
	}
	public String deleteComment(){
		infoCommentService.delete(this.getId(), BeanInfoComment.class);
		return findAll();
	}
}
